//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.batch;

import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.*;

public class BatchCmdPanel extends JPanel {

    public BatchCmdPanel() {
        jPanel = null;
        saveBatchButton = null;
        printBatchButton = null;
        clearButton = null;
        deleteButton = null;
        initialize();
    }

    private void initialize() {
        setSize(340, 36);
        add(getJPanel(), null);
    }

    private JPanel getJPanel() {
        if (jPanel == null) {
            FlowLayout flowLayout6 = new FlowLayout();
            jPanel = new JPanel();
            jPanel.setLayout(flowLayout6);
            jPanel.setPreferredSize(new Dimension(330, 26));
            flowLayout6.setHgap(2);
            flowLayout6.setVgap(2);
            flowLayout6.setAlignment(0);
            jPanel.add(getSaveBatchButton(), null);
            jPanel.add(getDeleteButton(), null);
            jPanel.add(getClearButton(), null);
            jPanel.add(getPrintBatchButton(), null);
        }
        return jPanel;
    }

    private JButton getSaveBatchButton() {
        if (saveBatchButton == null) {
            saveBatchButton = new JButton();
            saveBatchButton.setPreferredSize(new Dimension(22, 22));
            saveBatchButton.setContentAreaFilled(false);
            saveBatchButton.setBorderPainted(false);
            saveBatchButton.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/save.png")));
            saveBatchButton.setToolTipText("Enregistrer le lot");
            saveBatchButton.setFocusPainted(false);
        }
        return saveBatchButton;
    }

    private JButton getClearButton() {
        if (clearButton == null) {
            clearButton = new JButton();
            clearButton.setPreferredSize(new Dimension(22, 22));
            clearButton.setBorderPainted(false);
            clearButton.setContentAreaFilled(false);
            clearButton.setFocusPainted(false);
            clearButton.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/me/images/refresh.gif")));
            clearButton.setToolTipText("R\351initialiser les champs");
        }
        return clearButton;
    }

    private JButton getPrintBatchButton() {
        if (printBatchButton == null) {
            printBatchButton = new JButton();
            printBatchButton.setPreferredSize(new Dimension(22, 22));
            String s = "<html>G\351n\351rer l'impression des<br>\351tiquettes correspondantes<br>\340 la mise en stock.</html>";
            printBatchButton.setToolTipText(s);
            printBatchButton.setBorderPainted(false);
            printBatchButton.setFocusPainted(false);
            printBatchButton.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/printer.png")));
            printBatchButton.setContentAreaFilled(false);
        }
        return printBatchButton;
    }

    private JButton getDeleteButton() {
        if (deleteButton == null) {
            deleteButton = new JButton();
            deleteButton.setPreferredSize(new Dimension(22, 22));
            deleteButton.setBorderPainted(false);
            deleteButton.setContentAreaFilled(false);
            deleteButton.setFocusPainted(false);
            deleteButton.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/delete.png")));
            deleteButton.setToolTipText("Suprimer le lot");
        }
        return deleteButton;
    }

    public JButton getPrintBatch() {
        return getPrintBatchButton();
    }

    public JButton getSaveBatch() {
        return getSaveBatchButton();
    }

    public JButton getClear() {
        return getClearButton();
    }

    public JButton getDelete() {
        return getDeleteButton();
    }
    private JPanel jPanel;
    private JButton saveBatchButton;
    private JButton printBatchButton;
    private JButton clearButton;
    private JButton deleteButton;
}
